let disp = require("../../../../utils/broadcast");
var app = getApp()
Page({
  data: {
    username: {
      your: "",
    },
    show: !0,
    hide: !1,
    xing:0,
    evaluate:true,
    figure:0,// 0 患者     1 医生
    dex:"",//1 处方  ！1不是
    imgs:[
      "https://img1.dxycdn.com/2020/0308/949/3400928984622785985-22.jpg",
      "https://img1.dxycdn.com/2020/0308/949/3400928984622785985-22.jpg",
      "https://img1.dxycdn.com/2020/0308/949/3400928984622785985-22.jpg",
      "https://img1.dxycdn.com/2020/0308/949/3400928984622785985-22.jpg",
    ]
  },
  //查看详情  
  lookdetail(){
    wx.navigateTo({
      url: '/hyb_yl/zhuanjiasubpages/pages/zhifuend/zhifuend?txt=yes',
    })
  },
  //立即购买   
  atbuy(){
    wx.navigateTo({
      url: '/hyb_yl/backstageServices/pages/chufangjianyi/chufangjianyi',
    })
  },
  //图片预览
  lookimg(e){
    let url = e.currentTarget.dataset.img
    let lists = this.data.imgs
    wx.previewImage({
      current: url,
      urls: lists,
    })
  },
  //关闭追问
  closezhuiwen(){
    this.setData({
      figure:""
    })
  },
  //提交追问
  submitformzw(e){
    let val = e.detail.value.zhuiwen
  },
  //图片上传
  uploadimg(){
    wx.chooseImage({
      count: 1,
      sizeType: ['original', 'compressed'],
      sourceType: ['album', 'camera'],
      success(res) {
        // tempFilePath可以作为img标签的src属性显示图片
        const tempFilePaths = res.tempFilePaths
      }
    })
  },
  // 关闭评价
  closeevaluate(){
    this.setData({
      evaluate:false
    })
  },
  // 评分
  xingclick(e){
    let num = this.data.xing
    if (e.currentTarget.dataset.type == 'a'){
      this.setData({
        xing: e.currentTarget.dataset.num
      })
    }else{
      this.setData({
        xing: e.currentTarget.dataset.num + num
      })
    }
  },
  // 发布提问
  submitform(e){
    let vals = e.detail.value.liuyan;
  },
  // options = 系统传入的 url 参数
  onLoad(options) {
    console.log(options)
    var that = this
    if (options.useropenid) {
      var useropenid = options.useropenid
    } else {
      var useropenid = wx.getStorageSync('openid')
    }

    let bl_id = options.bl_id
    let z_name = options.z_name
    let username = JSON.parse(options.username);
    var orders = options.orders
    that.setData({
      username: username,
      useropenid: useropenid,
      orders: orders,
      z_name:options.z_name,
      list:options.list,
      dex: options.dex
    });
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    wx.setNavigationBarTitle({
      title: z_name
    });
    that.getuserone()
  },
  onShow:function(e){
    console.log(this.data.chufang)
    if (this.data.chufang){
      this.setData({
        
      })
    }
  },

  onUnload() {
    disp.fire("em.chatroom.leave");
  },

  onPullDownRefresh: function() {
    wx.showNavigationBarLoading();
    this.selectComponent('#chat').getMore()
    
    // 停止下拉动作
    wx.hideNavigationBarLoading();
    wx.stopPullDownRefresh();
  },
  //查询患者第一次问诊
  getuserone() {
    var that = this
    var bl_id = that.data.bl_id
    var openid = that.data.useropenid
    var orders = that.data.orders
    console.log(openid)
    app.util.request({
      'url': 'entry/wxapp/Tuwen.detail',
      data: {
        openid: openid,
        orders: orders
      },
      'cachetime': '30',
      success: function(res) {
        console.log(res)
        that.setData({
          msg: res.data
        })
      }
    })
  },
  clickshow: function(t) {
    this.setData({
      show: !0,
      hide: !1
    });
  },
  clickshow1: function(t) {
    this.setData({
      show: !1,
      hide: !0
    });
  }
});